<template>
  <div class="container">
    <el-dialog
      :title="drawerTitle"
      :visible.sync="drawerShow"
      :before-close="drawerClose"
      width="1000"
    >
      <div class="drawer-content">
        <el-form ref="form" :model="form" :rules="formRules" label-width="180px">
          <el-form-item label="专场标题：">
            {{form.title}}
          </el-form-item>
          <el-row>
            <el-col :span="8">
              <el-form-item label="附件简历投递：">
                <el-switch v-model="resumeConfig.attachmentResumeFlag" active-color="#13ce66" inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="期望职位：">
                <el-switch v-model="resumeConfig.configVO.workIntentions" active-color="#13ce66"
                           inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="工作/实习经历：">
                <el-switch v-model="resumeConfig.configVO.userWorkInfos" active-color="#13ce66"
                           inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="教育经历：">
                <el-switch v-model="resumeConfig.configVO.userEduInfos" active-color="#13ce66" inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="项目经历：">
                <el-switch v-model="resumeConfig.configVO.projectInfos" active-color="#13ce66" inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="培训经历：">
                <el-switch v-model="resumeConfig.configVO.trainInfos" active-color="#13ce66" inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="语言能力：">
                <el-switch v-model="resumeConfig.configVO.languageLevelInfos" active-color="#13ce66"
                           inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="职业特长与技能：">
                <el-switch v-model="resumeConfig.configVO.skillsInfos" active-color="#13ce66" inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="证书：">
                <el-switch v-model="resumeConfig.configVO.certificateInfos" active-color="#13ce66"
                           inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="家庭成员及重要社会关系：">
                <el-switch v-model="resumeConfig.configVO.familyMembers" active-color="#13ce66"
                           inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="附件：">
                <el-switch v-model="resumeConfig.configVO.files" active-color="#13ce66" inactive-color="#ff4949">
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="8">
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
          <el-button type="primary" :loading="loading" @click="submitForm()">保存</el-button>
          <el-button @click="drawerClose()">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import { resumeDeliveryConfigView,resumeDeliveryConfigEdit } from '@/api/resumeDeliveryConfig'

  export default {
    name: '',
    components: {},
    props: {},
    data() {
      return {
        drawerTitle: '简历配置',
        drawerShow: false,
        loading: false,
        form: {
          title: ''
        },
        formRules: {},
        resumeConfig: {}
      }
    },
    // 生命周期 - 创建完成（可以访问当前this实例）
    created() {
    },
    // 生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {
    },
    // 销毁
    destroyed() {
    },
    // 方法
    methods: {
      // 打开
      show(title, data) {
        this.drawerTitle = title
        this.form = data
        var param = {
          objId: data.id,
          configType: 'special_session'
        }
        resumeDeliveryConfigView(param).then((res) => {
          this.resumeConfig = res.result
          this.drawerShow = true
        }).catch(() => {
          this.loading = false
        })
      },
      // 关闭
      drawerClose() {
        this.$emit('refresh')
        this.$refs.form.resetFields()
        this.loading = false
        this.form = {
          title: ''
        }
        this.drawerShow = false
      },

      // 提交
      submitForm() {
        this.$refs.form.validate((valid) => {
          if (valid) {
            this.loading = true
            // const form = this.form
            const resumeConfig = this.resumeConfig
            resumeDeliveryConfigEdit(resumeConfig).then((res) => {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.drawerClose()
            }).catch(() => {
              this.loading = false
            })
          } else {
            return false
          }
        })
      }
    }
  }
</script>
